package mylib.archive.y2012.m08.SNSS_R4;

import mylib.dir.FastInputReader;
import mylib.dir.Graph;

import java.io.PrintWriter;
import java.util.LinkedList;
import java.util.Queue;

public class testA {
    public void solve(int testNumber, FastInputReader in, PrintWriter out) {
        int n = in.nextInt();
        int m = in.nextInt();
        Graph graph = new Graph(2 * m, n);
        for (int i = 0; i < m; ++i) {
            int x = in.nextInt() - 1;
            int y = in.nextInt() - 1;
            graph.addEdge(x, y);
            graph.addEdge(y, x);
        }
        int cmp = 0;
        boolean[] used = new boolean[n];
        for (int i = 0; i < n; ++i) {
            if (used[i])
                continue;
            Queue<Integer> queue = new LinkedList<Integer>();
            queue.add(i);
            used[i] = true;
            while (!queue.isEmpty()) {
                int p = queue.poll();
                for (Object o : graph.adjacentList(p)) {
                    int to = (Integer) o;
                    if (!used[to]) {
                        queue.add(to);
                        used[to] = true;
                    }
                }
            }
            ++cmp;
        }
        out.print(cmp == 1 ? "YES" : "NO");

    }
}
